<template>
  <div class="pop" v-show="isShow" @tap="isInnerShow = false">
    <div class="pop-inner" :class="{'show': isInnerShow}" @tap.stop="">
      <div class="pop-hd ta-c">
        <div v-if="hasHeaderOpt">
          <div class="title pd-l c-gray">{{title}}</div>
          <div class="close" @tap="isInnerShow = false"><i class="if icon-close"></i></div>
        </div>
        <slot name="header"></slot>
      </div>
      <div class="pop-bd pdh-l" style="max-height: 500px;overflow: scroll;"><slot></slot></div>
      <div class="pop-ft">
        <slot name="footer"></slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    value: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: '标题'
    },
    slotData: [Object],
    hasHeaderOpt: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      isShow: false,
      isInnerShow: false,
    }
  },
  mounted () {
  },
  watch: {
    value (nv) {
      if (nv) {
        this.isShow = true
        this.st = setTimeout(() => {
          this.isInnerShow = true
        }, 180)
      } else {
        this.isInnerShow = false
        if (this.st) clearTimeout(this.st1)
      }
    },
    isInnerShow (nv) {
      if (nv) {
        if (this.st) clearTimeout(this.st1)
      } else {
        this.st = setTimeout(() => {
          this.isShow = false
          this.$emit('input', false)
        }, 200)
      }
    },
  }
}
</script>

<style lang="less" scoped>
@import '../assets/less/var.less';
.pop {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: red;
  z-index: 2000;
  &-inner {
    position: absolute;
    width: 100%;
    left: 0;
    background-color: white;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    bottom: -100%;
    transition: bottom 200ms;
  }
  &-hd {
    text-align: center;
    position: relative;
    border-bottom: 1px solid #ddd;
    .close {
      position: absolute;
      width: 30px;
      height: 30px;
      line-height: 30px;
      text-align: center;
      right: 3px;
      top: 6px;
      i {
        font-size: 16px;
        color: @colorGray;
      }
    }
  }
  &-bd {
  }
}
.show {
  bottom: 0;
}
</style>
